#include<stdio.h>
int n;
int *unquie(int ints[])
{
    int boo =1;
    int q = 1000;
    while (boo)
    {
        boo = 0;
        for (int i = 0; i < n - 1; i++)
        {
            if (ints[i]>ints[i+1])
            {
                int temp;
                temp = ints[i];
                ints[i] = ints[i+1];
                ints[i+1] = temp;
                boo = 1;
            }
            if (ints[i] == ints[i+1])
            {
                ints[i] = q;
                q = q*10;
                ints[i+1] = q;
                q = q*10;
                boo = 1;
            }
            
        }
        
    }
    return ints;
    
}

int main(void)
{
    scanf("%d",&n);
    while (n!=0)
    { 
        int ints[20];
        for (int i = 0; i < n; i++)
        {
            scanf("%d",&ints[i]);
        }
        printf("%d\n",*(unquie(ints)));
        scanf("%d",&n);
    }
    
}